package com.dog.basics.netty.business.impl;

        import cn.hutool.core.lang.Validator;
        import cn.hutool.core.util.StrUtil;
        import com.dog.basics.bean.dto.api.mtkj.ApiGOrderAddDto;
        import com.dog.basics.common.util.SpringContextUtils;
        import com.dog.basics.netty.business.IBusinessServer;
        import com.dog.basics.netty.protobuf.dto.DogNewsContentDto;
        import com.dog.basics.netty.util.SessionSocketHolder;
        import com.dog.basics.service.mtkj.IMtDeviceOrderService;
        import io.netty.channel.ChannelHandlerContext;
        import lombok.extern.log4j.Log4j2;

/**
 * @description: 租赁轮椅 - 开锁
 * @author: He
 * @date: Created in 2020/10/12 12:20
 * @version: 1.0
 * @modified By:
 */
@Log4j2
public class ResponseHandlerImplRentingAWheelchair implements IBusinessServer<DogNewsContentDto.Message> {

    /**
     * @功能描述: 租赁轮椅开锁 - 执行
     * @author He
     * @date 2020/10/12
     */
    @Override
    public void businessHandler(ChannelHandlerContext ctx, DogNewsContentDto.Message msg) throws InterruptedException {
        log.info("租赁轮椅开锁:{}", msg.toString());
        // 锁设备标识
        Long dvId = SessionSocketHolder.getSession(ctx.channel().id().asLongText());
        // 获取通道标识 与 卡号标识 - 并且执行 msg.getIDcard();
        Boolean save4gObj = SpringContextUtils.getBean(IMtDeviceOrderService.class).save4gObj(ApiGOrderAddDto.builder().lockId(dvId).passNum(StrUtil.toString(msg.getLockport())).flage(Validator.equal(msg.getMsgCode(), 1)).build());
        System.out.println(StrUtil.format("租赁轮椅开锁:{}{}", msg.toString(), save4gObj));

    }
}